$(function(){
    $("body").delegate(".header-menu-btn", "click",
        function() {
            function m(e, f) {
                for (var g = e.length - 1; g >= 0; g--) {
                    var h = e[g];
                    if (h.substring(0, f.length + 1) == f + "=") {
                        return h.substring(f.length + 1)
                    }
                }
                return ""
            }
            var n = $(".header-menu", this.parentNode),
                o = $(".header-menu-bg");
            o.length ? o.css({
                display: "block"
            }) : ($("body").append('<div class="header-menu-bg"></div>'), o = $(".header-menu-bg"), o.on("click",
                function() {
                    $(".header-menu").removeClass("open"),
                        $(this).removeClass("open");
                    var b = this;
                    setTimeout(function() {
                            b.style.display = "none"
                        },
                        200)
                })),
                setTimeout(function() {
                        o.addClass("open")
                    },
                    20);
            var p,
                q,
                r,
                s = ("userid="+USERID+'&adminid='+ADMINID).split("&"),
                u = m(s, "userid"),
                a = m(s, "adminid"),
                w = encodeURIComponent(baseurl.substr(0, baseurl.length-1)+location.pathname + location.search + location.hash);
                c = baseurl+"mobile/member/center";
            if (parseFloat(u) > 0 || parseFloat(a)>0 ? (p = "logout", r = "退出", q = "login", w = 'javascript:unset_login();') : (p = "login", r = "登录/注册", q = "logout", w = baseurl+"mobile/member/login?referer=" + w), n.length) {
                if (0 === $("." + p, n).length) {
                    var x = $("." + q);
                    x.removeClass(q).addClass(p).prop("href", w).html("<i></i>" + r)
                }
            } else {
                $(this).after('<div class="header-menu"><a class="home touchable" href="'+basemobileurl+'"><i></i>首页</a><a class="my touchable" href="'+c+'"><i></i>个人中心</a><a class="' + p + ' touchable" href="' + w + '"><i></i>' + r + "</a></div>"),
                    n = $(".header-menu", this.parentNode)
            }
            setTimeout(function() {
                    n.addClass("open")
                },
                20)
        }),
        $("body").delegate(".page-back", "click", function() {
            var b = this.getAttribute("href");
            b && "javascript" === b.substring(0, 10).toLowerCase() && history.back();
        })
});